<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="/lib/echarts.min.js"></script>
    <script type="text/javascript" src="/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>


</head>

<body>
    <div id="main" style="width: 600px; height:400px"></div>

    <script>
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));



        $.ajax({
            "url": "http://localhost:8080/storage/numberBar",
            "data": {},
            "success": function (result) {
                var nameList=[];
                var outCount=[];
                var intoCount=[];

                var arr = result.data.namesBar;
                for(var i=0;i<arr.length;i++){
                    nameList.push(arr[i].name);
                    intoCount.push(arr[i].intoNumber)
                    outCount.push(arr[i].outNumber)
                }    


                // 指定图表的配置项和数据
                var option = {
  title: {
    text: '商品日出库入库量统计图'
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '0%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01]
  },
  yAxis: {
    type: 'category',
    data: nameList
  },
  series: [
    {
      name: '入库量',
      type: 'bar',
      data: intoCount
    },
    {
      name: '出库量',
      type: 'bar',
      data: outCount
    }
  ]
};

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);


            }
        })





    </script>
</body>

</html>